package com.ruoyi.buss.report.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.buss.report.domain.ReportMarketPerformanceLsb;
import com.ruoyi.buss.report.service.IReportMarketPerformanceLsbService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 营销任务进度历史记录，每天保存4.1.1Controller
 * 
 * @author sxy
 * @date 2021-07-16
 */
@RestController
@RequestMapping("/reportLsb")
public class ReportMarketPerformanceLsbController extends BaseController
{
    @Autowired
    private TokenService tokenService;

    @Autowired
    private IReportMarketPerformanceLsbService reportMarketPerformanceLsbService;

    /**
     * 查询营销任务进度历史记录，每天保存4.1.1列表
     * 营销任务进度表
     */
    @PreAuthorize(hasPermi = "buss:yxrwjdlsb:list")
    @GetMapping("/yxrwjdb")
    public TableDataInfo list(ReportMarketPerformanceLsb reportMarketPerformanceLsb)
    {
        LoginUser userInfo = tokenService.getLoginUser();

        startPage();
        List<ReportMarketPerformanceLsb> list =
                reportMarketPerformanceLsbService.
                            selectReportMarketPerformanceLsbList(reportMarketPerformanceLsb,userInfo, 0);
        return getDataTable(list);
    }

    /**
     * 查询营销任务进度历史记录，每天保存4.1.1列表
     * 营销任务进度表(总行汇总)
     */
/*    @PreAuthorize(hasPermi = "buss:yxrwjdlsb:yxrwjdbhz")
    @GetMapping("/yxrwjdbhz")
    public TableDataInfo yxrwjdbhz(ReportMarketPerformanceLsb reportMarketPerformanceLsb)
    {
        LoginUser userInfo = tokenService.getLoginUser();

        List<ReportMarketPerformanceLsb> list =
                reportMarketPerformanceLsbService.
                        selectReportMarketPerformanceLsbList(reportMarketPerformanceLsb,userInfo,1);
        return getDataTable(list);
    }*/

    /**
     * 查询营销任务进度历史记录，每天保存4.1.1列表
     * 营销任务进度表(汇总支行)
     */
    @PreAuthorize(hasPermi = "buss:yxrwjdlsb:yxrwjdbListZh")
    @GetMapping("/yxrwjdbListZh")
    public TableDataInfo yxrwjdbListZh(ReportMarketPerformanceLsb reportMarketPerformanceLsb)
    {
        LoginUser userInfo = tokenService.getLoginUser();

        startPage();
        List<ReportMarketPerformanceLsb> list =
                reportMarketPerformanceLsbService.
                        selectReportMarketPerformanceLsbList(reportMarketPerformanceLsb,userInfo,4);
        return getDataTable(list);
    }

    /**
     * 导出营销任务进度历史记录，每天保存4.1.1列表
     * 营销任务进度表(总行汇总)
     */
/*    @PreAuthorize(hasPermi = "buss:yxrwjdlsb:yxrwjdbListZhhz")
    @Log(title = "营销任务进度历史记录，每天保存4.1.1", businessType = BusinessType.EXPORT)
    @PostMapping("/yxrwjdbListZhhz")
    public void export(HttpServletResponse response, ReportMarketPerformanceLsb reportMarketPerformanceLsb) throws IOException
    {
        LoginUser userInfo = tokenService.getLoginUser();

        startPage();
        List<ReportMarketPerformanceLsb> list =
                reportMarketPerformanceLsbService.
                        selectReportMarketPerformanceLsbList(reportMarketPerformanceLsb,userInfo,6);
        ExcelUtil<ReportMarketPerformanceLsb> util = new ExcelUtil<ReportMarketPerformanceLsb>(ReportMarketPerformanceLsb.class);
        util.exportExcel(response, list, "营销任务进度历史记录，每天保存4.1.1数据");
    }*/

       /**
     * 获取营销任务进度历史记录，每天保存4.1.1详细信息
     */
    @PreAuthorize(hasPermi = "buss:yxrwjdlsb:query")
    @GetMapping(value = "/{sjrq}")
    public AjaxResult getInfo(@PathVariable("sjrq") String sjrq)
    {
        return AjaxResult.success(reportMarketPerformanceLsbService.selectReportMarketPerformanceLsbById(sjrq));
    }

    /**
     * 新增营销任务进度历史记录，每天保存4.1.1
     */
    @PreAuthorize(hasPermi = "buss:yxrwjdlsb:add")
    @Log(title = "营销任务进度历史记录，每天保存4.1.1", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReportMarketPerformanceLsb reportMarketPerformanceLsb)
    {
        return toAjax(reportMarketPerformanceLsbService.insertReportMarketPerformanceLsb(reportMarketPerformanceLsb));
    }

    /**
     * 修改营销任务进度历史记录，每天保存4.1.1
     */
    @PreAuthorize(hasPermi = "buss:yxrwjdlsb:edit")
    @Log(title = "营销任务进度历史记录，每天保存4.1.1", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ReportMarketPerformanceLsb reportMarketPerformanceLsb)
    {
        return toAjax(reportMarketPerformanceLsbService.updateReportMarketPerformanceLsb(reportMarketPerformanceLsb));
    }

    /**
     * 删除营销任务进度历史记录，每天保存4.1.1
     */
    @PreAuthorize(hasPermi = "buss:yxrwjdlsb:remove")
    @Log(title = "营销任务进度历史记录，每天保存4.1.1", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sjrqs}")
    public AjaxResult remove(@PathVariable String[] sjrqs)
    {
        return toAjax(reportMarketPerformanceLsbService.deleteReportMarketPerformanceLsbByIds(sjrqs));
    }
}
